package com.mdd.admin.controller.system;

import com.mdd.admin.config.aop.Log;
import com.mdd.admin.service.system.ICouponReceiveService;
import com.mdd.admin.validate.system.CouponReceiveCancelParam;
import com.mdd.admin.validate.system.CouponReceiveParam;
import com.mdd.admin.validate.common.PageParam;
import com.mdd.admin.vo.system.CouponReceiveListVo;
import com.mdd.admin.vo.system.CouponReceiveDetailVo;
import com.mdd.common.core.AjaxResult;
import com.mdd.common.core.PageResult;
import com.mdd.common.validator.annotation.IDMust;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 领取记录管理
 * @author panweiliang
 */
@RestController
@RequestMapping("api/system/coupon_receive")
public class CouponReceiveController {

    @Resource
    ICouponReceiveService iCouponReceiveService;

    /**
     * 领取记录列表
     *
     * @author panweiliang
     * @param pageParam 分页参数
     * @param params 搜索参数
     * @return Object
     */
    @GetMapping("/list")
    public Object list(@Validated PageParam pageParam,
                       @RequestParam Map<String, String> params) {
        PageResult<CouponReceiveListVo> list = iCouponReceiveService.list(pageParam, params);
        return AjaxResult.success(list);
    }

    /**
     * 作废领取记录
     *
     * @author panweiliang
     * @param couponReceiveCancelParam 参数
     * @return Object
     */
    @Log(title = "作废领取记录")
    @PostMapping("/cancel")
    public Object cancel(@RequestBody CouponReceiveCancelParam couponReceiveCancelParam) {
        iCouponReceiveService.cancel(couponReceiveCancelParam.getId());
        return AjaxResult.success();
    }


    /**
     * 领取记录不同状态个数
     *
     * @author panweiliang
     * @return Object
     */
    @GetMapping("/count")
    public Object count() {
        Map<String, Object> map = iCouponReceiveService.count();
        return AjaxResult.success(map);
    }

}
